package com.tdkj.service.user.impl;

import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.tdkj.dao.user.IBeanFriendCategoryDao;
import com.tdkj.model.base.BaseEntity;
import com.tdkj.model.user.BeanFriendCategory;
import com.tdkj.model.user.BeanUser;
import com.tdkj.service.BaseService;
import com.tdkj.service.user.IBeanFriendCategoryService;

@Component("friendCategoryService")
public class BeanFriendCategoryServiceImpl extends BaseService  implements IBeanFriendCategoryService{
	private IBeanFriendCategoryDao categoryDao;

	public IBeanFriendCategoryDao getCategoryDao() {
		return categoryDao;
	}

	@Resource
	public void setCategoryDao(IBeanFriendCategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	@Override
	public BeanFriendCategory findDefaultCategory(Long id) {
		BeanUser u=this.getBaseDao().findById(id, BeanUser.class);
		BeanFriendCategory c=null;
		List<BeanFriendCategory> l=u.getFriendCategorys();
		if(l.size()==0){
			
		}else{
			for(int i=0;i<l.size();i++){
				String cname=l.get(i).getName();
				if(cname.equals("默认")){
					c=l.get(i);
				}
			}
			if(c==null){
				c=new BeanFriendCategory();
				c.setName("默认");
				c.setUser(u);
				this.getBaseDao().save(c);
			}
		}
		return c;
	}

	@Override
	public <T extends BaseEntity> List<T> findAll(Class<T> clazz,
			LinkedHashMap<String, String> orderInfos) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T extends BaseEntity> List<T> findByExample(T t,
			LinkedHashMap<String, String> orderInfos) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T extends BaseEntity> List<T> findByProperty(String propertyName,
			Object value, Class<T> clazz,
			LinkedHashMap<String, String> orderInfos) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
